Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yauzl-promise

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yauzl-promise

Unzip library for NodeJS

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
426K
increased by82.41%
Maintainers
1
Weekly downloads
 
Created

What is yauzl-promise?

The 'yauzl-promise' npm package is a promise-based wrapper around the 'yauzl' library, which is used for unzipping files. It simplifies the process of working with ZIP files by providing a more modern, promise-based API.

What are yauzl-promise's main functionalities?

Open a ZIP file

This feature allows you to open a ZIP file asynchronously. The code sample demonstrates how to open a ZIP file and log the resulting zipFile object.

const yauzl = require('yauzl-promise');

async function openZip(filePath) {
  const zipFile = await yauzl.open(filePath);
  console.log('ZIP file opened:', zipFile);
}

openZip('path/to/your.zip');

Read entries in a ZIP file

This feature allows you to read the entries in a ZIP file. The code sample demonstrates how to open a ZIP file, read its entries, and log the file names of each entry.

const yauzl = require('yauzl-promise');

async function readEntries(filePath) {
  const zipFile = await yauzl.open(filePath);
  const entries = await zipFile.readEntries();
  entries.forEach(entry => {
    console.log('Entry:', entry.fileName);
  });
}

readEntries('path/to/your.zip');

Extract a file from a ZIP archive

This feature allows you to extract a specific file from a ZIP archive. The code sample demonstrates how to open a ZIP file, read a specific entry, and extract it to a specified output path.

const yauzl = require('yauzl-promise');
const fs = require('fs');

async function extractFile(filePath, entryName, outputPath) {
  const zipFile = await yauzl.open(filePath);
  const entry = await zipFile.readEntry(entryName);
  const readStream = await entry.openReadStream();
  const writeStream = fs.createWriteStream(outputPath);
  readStream.pipe(writeStream);
}

extractFile('path/to/your.zip', 'file/inside/zip.txt', 'output/path.txt');

Other packages similar to yauzl-promise

Keywords

FAQs

Package last updated on 18 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc